#include "udpserve.hpp"
#include <memory>
#include <cstdio>

using std::stoi;
using std:: unique_ptr;

void Usage(std::string proc)
{
    std::cout << "\n\rUsage: " << proc << " port[1024+]\n" << std::endl;
}

string print(const string& s){
    string res = "server get a message: ";
    res += s;
    cout << res << endl;
    return res;
}

int main(int argc, char* argv[]){
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(0);
    }
    uint16_t port = stoi(argv[1]);
    unique_ptr<Udpserve> us(new Udpserve(port));

    us->init();

    us->run(print);

    return 0;
}